home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / developer_install / CEGUISDK-0.4.1-VC6-Native.exe / {app} / Samples / Demo8 / src / Sample_Demo8.cpp next >
Encoding:
C/C++ Source or Header  |  2005-08-21  |  3.3 KB  |  83 lines

  1. /************************************************************************
  2.     filename:   Sample_Demo8.cpp
  3.     created:    20/8/2005
  4.     author:     Paul D Turner
  5. *************************************************************************/
  6. /*************************************************************************
  7.     Crazy Eddie's GUI System (http://www.cegui.org.uk)
  8.     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
  9.  
  10.     This library is free software; you can redistribute it and/or
  11.     modify it under the terms of the GNU Lesser General Public
  12.     License as published by the Free Software Foundation; either
  13.     version 2.1 of the License, or (at your option) any later version.
  14.  
  15.     This library is distributed in the hope that it will be useful,
  16.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18.     Lesser General Public License for more details.
  19.  
  20.     You should have received a copy of the GNU Lesser General Public
  21.     License along with this library; if not, write to the Free Software
  22.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  23. *************************************************************************/
  24. #include "Sample_Demo8.h"
  25. #include "CEGUI.h"
  26. #include "CEGUILua.h"
  27.  
  28. #if defined( __WIN32__ ) || defined( _WIN32 )
  29. #define WIN32_LEAN_AND_MEAN
  30. #include "windows.h"
  31.  
  32. int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
  33. #else
  34. int main(int argc, char *argv[])
  35. #endif
  36. {
  37.     // This is a basic start-up for the sample application which is
  38.     // object orientated in nature, so we just need an instance of
  39.     // the CEGuiSample based object and then tell that sample application
  40.     // to run.  All of the samples will use code similar to this in the
  41.     // main/WinMain function.
  42.     Demo8Sample app;
  43.     return app.run();
  44. }
  45.  
  46.  
  47. /*************************************************************************
  48.     Sample specific initialisation goes here.
  49. *************************************************************************/
  50. bool Demo8Sample::initialiseSample()
  51. {
  52.     using namespace CEGUI;
  53.  
  54.     // get a pointer to the renderer created by the base app object.
  55.     Renderer* renderer = System::getSingleton().getRenderer();
  56.  
  57.     // delete the CEGUI::System created by the base app.
  58.     //
  59.     // NB:  You would not normally do this, we're doing this here
  60.     // since we need to re-initialise everything in order to use the
  61.     // scripting support.
  62.     delete System::getSingletonPtr();
  63.  
  64.     // create a script module.
  65.     LuaScriptModule* scriptmod = new LuaScriptModule();
  66.  
  67.     // now re-create the CEGUI::System passing in our scripting module
  68.     // and basically 'bootstrapping' the demo via a config file.
  69.     new System(renderer, scriptmod, (utf8*)"../datafiles/configs/demo8.config");
  70.  
  71.     // success!
  72.     return true;
  73. }
  74.  
  75. /*************************************************************************
  76.     Cleans up resources allocated in the initialiseSample call.
  77. *************************************************************************/
  78. void Demo8Sample::cleanupSample()
  79. {
  80.     // This is a bit dangerous!
  81.     delete CEGUI::System::getSingleton().getScriptingModule();
  82. }
  83.